package com.mvpandroiddemo.fragment.main;


import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import androidx.viewpager.widget.ViewPager;

import com.mvpandroiddemo.R;
import com.mvpandroiddemo.base.BaseFragment;
import com.mvpandroiddemo.search.SearchActivity;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * A simple {@link Fragment} subclass.
 */
public class MainFragment extends BaseFragment implements MainContract.IMainView {


    @BindView(R.id.main_search_iv)
    AppCompatImageView searchIv;

    @BindView(R.id.main_banner_vp)
    ViewPager bannerVp;

    @BindView(R.id.main_content_rv)
    RecyclerView contentRv;

    private IMainPresentImp mainPresentImp;

    public MainFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mainPresentImp = new IMainPresentImp();
        mainPresentImp.attachView(this);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View rootView = inflater.inflate(R.layout.fragment_main, container, false);
        ButterKnife.bind(this, rootView);
        initView();
        return rootView;
    }

    private void initView() {
//        contentRv.setAdapter();
    }


    @OnClick(R.id.main_search_iv)
     void onViewClicked() {
        startActivity(new Intent(mContext, SearchActivity.class));
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mainPresentImp != null) {
            mainPresentImp.detachView();
        }
    }
}
